#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    vector<int> plusOne(vector<int>& digits)
    {
        int index = digits.size() - 1;
        digits[index]++;
        while (digits[index] == 10) {
            digits[index--] = 0;
            if (index < 0)
                break;
            digits[index]++;
        }
        if (index < 0)
            digits.insert(digits.begin(), 1);
        return digits;
    }
};

int main(int argc, char const* argv[])
{
    Solution temp;
    int a[4] = { 9, 9, 9, 9 };
    vector<int> digits(a, a + 4);
    temp.plusOne(digits);
    return 0;
}